package com.damie.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dadie.Dto.UserDto;
import com.dadie.parame.UserParame;
import com.damie.common.commonutils.R;
import com.damie.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Alon
 * @since 2021-01-22
 */
@Api(value="用户管理controller",tags={"后台:用户管理"})
@RestController
@CrossOrigin("*")
@RequestMapping("/damie/user")
public class UserController {

    @Resource
    private UserService service;
    @ApiOperation("分页查询所有用户")
    @PostMapping("selectAllUser")
    public R selectAllUser(Integer index, Integer size, @RequestBody UserParame userParame){
        Page<UserDto> list = service.selectAllUser(index,size,userParame);
        return R.ok().data("userList",list);
    }
    @ApiOperation("单独查询某个用户")
    @GetMapping("selectByIdUser")
    public R selectByIdUser(String id){
        UserDto list = service.selectByIdUser(id);
        return R.ok().data("user",list);
    }
    @ApiOperation("删除某个用户")
    @GetMapping("deleteByIdUser")
    public R deleteByIdUser(String id){
        UserDto list = service.deleteByIdUser(id);
        return R.ok().data("user",list);
    }

    @ApiOperation("修改某个用户")
    @PutMapping("updateByIdUser")
    public R updateByIdUser(@RequestBody UserParame userParame){
        UserDto list = service.updateByIdUser(userParame);
        return R.ok().data("user",list);
    }
}

